<script type="text/javascript" src="{$base_dir}modules/dept_emer/js/AJAX_EmerTestProcess.js"></script>
{literal}
<script type="text/javascript">
$(document).ready(function(){
    
    $('#testList').bind('click',function(){

        var selected = $('#testList :selected');

        if (selected != null) {
        	    $('#isTestTicketDone').attr('disabled','');
                $('#testAssignDoctorName').html(selected.attr('doctor_name'));
                $('#testAssignDiagnosis').html(selected.attr('diagnosis'));
                loadTestItem4InputResult('{/literal}{$ticketId}{literal}', selected.val());
                if (selected.attr('is_done') == 0) {
                	$('#isTestTicketDone').attr('checked','');
                    
                } else {
                	$('#isTestTicketDone').attr('checked','checked');
                    
                }
                          

        } else {
        	$('#isTestTicketDone').attr('disabled','disabled');
        }
    });

    $('#testList').bind('change',function(){

    	 var selected = $('#testList :selected');

         if (selected != null) {
                 $('#isTestTicketDone').attr('disabled','');
                 $('#testAssignDoctorName').html(selected.attr('doctor_name'));
                 $('#testAssignDiagnosis').html(selected.attr('diagnosis'));
                 loadTestItem4InputResult('{/literal}{$ticketId}{literal}', selected.val());
                 if (selected.attr('is_done') == 0) {
                     $('#isTestTicketDone').attr('checked','');
                     
                 } else {
                     $('#isTestTicketDone').attr('checked','checked');
                     
                 }          

         } else {
             $('#isTestTicketDone').attr('disabled','disabled');
         }
    });

    $('#saveInputedTestItemResult').bind('click',function(){

        var testTicketId = $('#testList :selected').val();
        if (testTicketId != null && $.trim(testTicketId) != '') {
        	saveInputedTestItemResult('{/literal}{$ticketId}{literal}', testTicketId);
            
        }
    });

    $('#isTestTicketDone').bind('click', function() {
    	var testTicketId = $('#testList :selected').val();
        if (testTicketId != null && $.trim(testTicketId) != '') {
             
        	 if ($(this).is(':checked') == true) {
                 updateDoneTestTicket('{/literal}{$ticketId}{literal}',testTicketId, 1);
             } else {
                 updateDoneTestTicket('{/literal}{$ticketId}{literal}',testTicketId, 0);
             }  
         }
    });
    
    
    
    
    
})
</script>
{/literal}

<table class="grid inline" width="100%">
	<tr>
		<td width="200px;">

		<table class="grid inline">
			<tr>
				<td>
				<table class="grid inline" style="width: 100%; height: 100%;">
					<tr>
						<td><span id="statusMessage"
							style="font-style: italic; color: red;"></span></td>
					</tr>

					<tr>
						<td colspan="3">{translate}List of test ticket{/translate}
					</tr>
					<tr>
						<td colspan="3"><select style="width: 230px;" size="8"
							multiple="true" id="testList">
							{foreach from=$listOfAssignedTest item=assignedTest key=key}
							<option value='{$assignedTest.test_diagnosis_ticket_id}'
								requested_time='{$assignedTest.requested_time}'
								diagnosis='{$assignedTest.diagnosis}'
								ticket_id='{$assignedTest.ticket_id}'
								doctor_name='{$assignedTest.doctor_name}'
								doctor_id='{$assignedTest.doctor_id}'
								is_done='{$assignedTest.is_done}'>{if
							($assignedTest.is_done == 0)}
							{$assignedTest.requested_time}&nbsp;[{translate}InProgess{/translate}]
							{else}
							{$assignedTest.requested_time}&nbsp;[{translate}Done{/translate}]
							{/if}</option>
							{/foreach}
						</select></td>
					</tr>
				</table>
				</td>
				<td>
				<table class="inline" style="vertical-align: top;">
					<tr>
						<td width="80px;" class="label">{translate}Doctor{/translate}:</td>
						<td width="100px;"><span id="testAssignDoctorName"
							style="color: #000;"></span></td>
						<td>
						<div id="reloadInputTestResult"
							style="display: none; width: 100px;" align="right"><a
							href="javascript:loadTestForm('{$ticketId}');"
							title="{translate}Update list of patients{/translate}"><img
							src="{$base_uri}/images/refresh.png" /></a></div>
						<div id="innerInputTestResult"
							style="display: block; width: 100px;" align="right"><img
							src="{$base_uri}/images/ajax-loader.gif" /></div>
						</td>
					</tr>
					<tr>
						<td class="label">{translate}Diagnosis{/translate}:</td>

					</tr>
					<tr>
						<td class="field" rowspan="2" colspan="3"><textarea rows="3"
							cols="1" style="width: 300px" id="testAssignDiagnosis"
							readonly="readonly"></textarea></td>
					</tr>
					<tr></tr>
					<tr>
						<td class="label">{translate}Done{/translate}:</td>
						<td>{if ($testItem.is_done == 0)} <input type="checkbox"
							id="isTestTicketDone"
							value="{$assignedTest.test_diagnosis_ticket_id}"
							disabled="disabled"> {else} <input type="checkbox"
							id="isTestTicketDone"
							value="{$assignedTest.test_diagnosis_ticket_id}"
							checked="checked" disabled="disabled"> {/if}
						<td>
					</tr>
				</table>
				</td>
			</tr>
		</table>

		</td>
	</tr>
</table>
<br>
<table class="grid inline">
	<tr>
		<td class="label">{translate}Assigned tests{/translate} :</td>
	</tr>
</table>
<div id="inputTestItemResult">{include
file="emer_test_input_result/general_test_item_input.html"}</div>
<br>
<table width="100%">
	<tr>
		<td width="95%" align="right"><span id="resultMessage"
			style="font-style: italic; color: red;"></span></td>
		<td><input type="button" id="saveInputedTestItemResult"
			value="{translate}Save{/translate}"></td>
	</tr>
</table>




